<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    <script>
        var obj = {
            name:'lucy',
            age:18
        }
        var value 
        // vue引擎 Object.defineProperty  对象劫持 第一个数据劫持对象 第二个 KEY
        Object.defineProperty(obj,'name',{
            get:function(){
                console.log('读数据的时候进来')
                return value 
            },
            set:function(newvalue) {
                console.log('set 设置数据的时候进来') 
                value = newvalue
            }
        })

        console.log(obj.name)
        obj.name ='jack'
        console.log(obj.name)

        console.log(obj.age)
    </script>
</body>
</html>